﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;

namespace SSOCommon
{
    public class Command
    {

        public string Sender
        {
            get;
            set;
        }

        public string Action
        {
            get;
            set;
        }

        public Command()
        { }

        public Command(string action)
        {
            this.Action = action;
        }

        public static Command ParseCommand(NameValueCollection input)
        {
            if (input == null || input.Keys.Count == 0)
            {
                return new Command(((int)SSOAction.None).ToString());
            }
            string sender = input[ArgumentConstant.SENDER] == null ? String.Empty : input[ArgumentConstant.SENDER];
            string action = input[ArgumentConstant.ACTION] == null ? ((int)SSOAction.None).ToString() : input[ArgumentConstant.ACTION];
            return new Command() { Sender = sender, Action = action };


        }
    }
}
